package com.hfzy.ihk.common.core.elasticsearch;

import com.google.common.collect.Lists;
import com.hfzy.ihk.common.facade.BaseEntity;

import java.util.Date;
import java.util.List;

/**
 *  指除了主业务表操作以外的其他表的保存或更新操作，
 *  这部分操作采用最大努力和补偿逻辑来保证成功（最终一致的思路）
 * @author wws
 * @since 2018-01-13
 */

public class ElasticsearchOperation {

    private static final long serialVersionUID = 1L;

	/**事务ID，主要对一批操作标识为同一事务的*/
	private String txId;

	private String optTable;

	private String optMethod;

	private List data;

	private Date createTime = new Date();

	private boolean fromJobRun;

	public ElasticsearchOperation() {
	}

	public ElasticsearchOperation(String txId, String optTable, String optMethod, List data) {
		this.txId = txId;
		this.optTable = optTable;
		this.optMethod = optMethod;
		this.data = data;
	}
	public ElasticsearchOperation(String txId, String optTable, String optMethod, Object data) {
		this.txId = txId;
		this.optTable = optTable;
		this.optMethod = optMethod;
		this.data = Lists.newArrayList(data);
	}

	public String getTxId() {
		return txId;
	}

	public void setTxId(String txId) {
		this.txId = txId;
	}

	public String getOptTable() {
		return optTable;
	}

	public void setOptTable(String optTable) {
		this.optTable = optTable;
	}

	public String getOptMethod() {
		return optMethod;
	}

	public void setOptMethod(String optMethod) {
		this.optMethod = optMethod;
	}

	public List getData() {
		return data;
	}

	public void setData(List<BaseEntity> data) {
		this.data = data;
	}

	public Date getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

	public boolean isFromJobRun() {
		return fromJobRun;
	}

	public void setFromJobRun(boolean fromJobRun) {
		this.fromJobRun = fromJobRun;
	}
}
